package com.xcity.game.activity.newplayer.tracer;

import java.text.MessageFormat;
import java.util.List;

import com.xcity.db.entity.Employee;
import com.xcity.db.entity.Player;
import com.xcity.game.activity.newplayer.NewPlayerDoingStr;
import com.xcity.game.activity.newplayer.NewPlayerTask;
import com.xcity.game.activity.newplayer.NewPlayerTracer;
import com.xcity.game.activity.newplayer.NewPlayerTracerLabel;
import com.xcity.pomelo.response.EquipmentBagResponse.EquipmentSuit;

@NewPlayerTracerLabel(NewPlayerTracer.EQUIP_SUIT_COUNT)
public class EquipSuitCountTracer implements NewPlayerTracer{

	@Override
	public boolean isDone(NewPlayerTask task) {
		int count = task.getTemplate().getParam()[0];
		if(task.getVm().getOwner().suitCount() >= count){
			return true;
		}
		return false;
	}

	@Override
	public void onChange(NewPlayerTask task, Object... vals) {
		Player player = (Player)vals[0];
		List<EquipmentSuit> list = ((Employee)vals[1]).getEquipSuits();
		for(int i = 0; i < list.size(); i++){
			player.tryAddSuit(list.get(i).brand.ordinal());
		}
	}

	@Override
	public String getDoingStr(NewPlayerTask task) {
		return MessageFormat.format(NewPlayerDoingStr.STR_EQUIP_SUIT_COUNT, task.getTemplate().getParam()[0]);
	}

}
